<%@ page import="com.tencent.albert.weixin.driver.bean.*" %>
<%@ page import="com.tencent.albert.weixin.driver.utils.WeixinUtil" %>
<%@ page import="com.tencent.albert.weixin.driver.Constants" %>
<%--
    Document   : createMenu
    Created on : 2014-12-25, 17:58:45
    Author     : albertzhu
--%>


<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%!
    private static Menu getMenu() {


        ViewButton btn12 = new ViewButton();
        btn12.setName("免佣公寓");
        btn12.setType("view");
        btn12.setUrl("http://url.cn/aZn3dD");
        
        ViewButton btn11 = new ViewButton();
        btn11.setName("个人房源");
        btn11.setType("view");
        btn11.setUrl("http://www.xiaoluo.com/m/RentCircle");



        ClickButton btn13 = new ClickButton();
        btn13.setName("免佣小秘书");
        btn13.setType("click");
        btn13.setKey("BTN_CLICK_FOR_mishu");
        
        ViewButton btn14 = new ViewButton();
        btn14.setName("下载App");
        btn14.setType("view");
        btn14.setUrl("http://m.xiaoluo.com/AppDown");
        
        /*
        ViewButton btn13 = new ViewButton();
        btn13.setName("在线咨询");
        btn13.setType("view");
        btn13.setUrl("http://www.52xiaoluo.com/promotion/0130/guide.html");
        
        
        ViewButton btn14 = new ViewButton();
        btn14.setName("推荐房源");
        btn14.setType("view");
        btn14.setUrl("http://m.xiaoluo.com/recommand/home");
        */

        ComplexButton mainBtn1 = new ComplexButton();
        mainBtn1.setName("我要找房");
        mainBtn1.setSub_button(new Button[]{btn12,btn11, btn13,btn14});


       

        ViewButton btn22 = new ViewButton();
        btn22.setName("短租优惠");
        btn22.setType("view");
        btn22.setUrl("http://url.cn/aKYdpy");

        ViewButton btn23 = new ViewButton();
        btn23.setName("老租客福利");
        btn23.setType("view");
        btn23.setUrl("http://url.cn/Ykrfmw");

        ClickButton btn21 = new ClickButton();
        btn21.setName("商务合作");
        btn21.setType("click");
        btn21.setKey("BTN_CLICK_FOR_COOPERATE");


        ComplexButton mainBtn2 = new ComplexButton();
        mainBtn2.setName("最新活动");
        mainBtn2.setSub_button(new Button[]{btn22,btn23,btn21});
        
        
        

        ViewButton btn31 = new ViewButton();
        btn31.setName("我的预约");
        btn31.setType("view");
        btn31.setUrl("http://m.xiaoluo.com/ViewOrder/home");

        ViewButton btn32 = new ViewButton();
        btn32.setName("我的收藏");
        btn32.setType("view");
        btn32.setUrl("http://m.xiaoluo.com/Collection");

        ViewButton btn33 = new ViewButton();
        btn33.setName("推荐房源");
        btn33.setType("view");
        btn33.setUrl("http://m.xiaoluo.com/recommand/home");
        
        ViewButton btn35 = new ViewButton();
        btn35.setName("我有建议");
        btn35.setType("view");
        btn35.setUrl("https://jinshuju.net/f/Pey4Id");

        ViewButton btn34 = new ViewButton();
        btn34.setName("在线咨询");
        btn34.setType("view");
        btn34.setUrl("http://www.52xiaoluo.com/promotion/0130/guide.html");


        ComplexButton mainBtn3 = new ComplexButton();
        mainBtn3.setName("我的小螺");
        mainBtn3.setSub_button(new Button[]{btn31,btn32,btn33,btn35,btn34});
        


        /**
         * 这是公众号xiaoqrobot目前的菜单结构，每个一级菜单都有二级菜单项<br>
         *
         * 在某个一级菜单下没有二级菜单的情况，menu该如何定义呢？<br>
         * 比如，第三个一级菜单项不是“更多体验”，而直接是“幽默笑话”，那么menu应该这样定义：<br>
         * menu.setButton(new Button[] { mainBtn1, mainBtn2, btn33 });
         */
        Menu menu = new Menu();
        menu.setButton(new Button[]{ mainBtn1, mainBtn2, mainBtn3});

        return menu;


    }
%>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>

<%
    // 调用接口获取access_token
    AccessToken at = WeixinUtil.getAccessToken(Constants.appId, Constants.appSecret);

    if (null != at) {
        // 调用接口创建菜单
        //int result = WeixinUtil.createMenu(getMenu(), at.getAccess_Token());
        int result = 0;
        // 判断菜单创建结果
        if (0 == result) {
            out.println("菜单创建成功！");
        } else {
            out.println("菜单创建失败，错误码：" + result);
        }
    }

%>

</body>
</html>
